﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SpaceBattle.Utilities;
using SpaceBattle.Viev;

namespace SpaceBattle.Graphics
{
    class Radar : DrawableGameComponent
    {
        private float scale = 40;
        private Vector2 position;
        private List<Body> bodyList;
        private Texture2D texture;
        private Texture2D texture2;

        public Radar(List<Body> bodyList):base(GameMain.Game())
        {
            position = new Vector2(250,250);
            texture = TextureLoader.Textures().radarDotTex;
            texture2 = TextureLoader.Textures().radarTex;
            this.bodyList = bodyList;
            GameMain.Game().Components.Add(this);
        }

        public override void Draw(GameTime gameTime)
        {
            GameMain.Game().SolidBatch.Draw(TextureLoader.Textures().radarTex, position, new Rectangle(0, 0, texture2.Width, texture2.Height),
               Color.White, 0, new Vector2(texture2.Width / 2, texture2.Height / 2), 20/scale, SpriteEffects.None, 0);

            foreach (var body in bodyList)
            {
                GameMain.Game().SolidBatch.Draw(texture, body.Position/scale+position, new Rectangle(0, 0, texture.Width, texture.Height),
               body.Color, 0, new Vector2(texture.Width / 2, texture.Height / 2), MathHelper.Clamp(body.Size/scale/scale,.4f,10f), SpriteEffects.None, 0);
            }
        }
    }
}
